package com.zixuan.sina.utils;

import com.aliyun.oss.OSS;
import com.aliyun.oss.model.PartETag;
import com.aliyun.oss.model.UploadPartRequest;
import com.aliyun.oss.model.UploadPartResult;

import java.util.List;

public class UploadPartTask  implements Runnable{
    private OSS ossClient;
    private UploadPartRequest uploadPartRequest;
    private List<PartETag> partETags;

    public UploadPartTask(OSS ossClient, UploadPartRequest uploadPartRequest, List<PartETag> partETags) {
        this.ossClient = ossClient;
        this.uploadPartRequest = uploadPartRequest;
        this.partETags = partETags;
    }

    @Override
    public void run() {
        UploadPartResult uploadPartResult = ossClient.uploadPart(uploadPartRequest);
        synchronized (partETags) {
            partETags.add(uploadPartResult.getPartETag());
        }
    }
}

